Create "Formatted" validator#1657
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1657 +/- ##
============================================
- Coverage 99.56% 99.56% -0.01%
+ Complexity 970 969 -1
============================================
Files 193 193
Lines 2280 2277 -3
============================================
- Hits 2270 2267 -3
Misses 10 10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Formatted validator that decorates another validator to transform how input values appear in error messages while validating the original unmodified input. This enhances error message readability by displaying values in user-friendly formats using the Respect\StringFormatter library.
Changes:
- Added
Formattedvalidator implementation that wraps another validator and formats the input value displayed in error messages - Added comprehensive unit and feature tests for the new validator
- Updated all mixin interfaces to include the new
formatted()method for fluent API support
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Validators/Formatted.php | New validator that decorates another validator to format input values in error messages |
| tests/unit/Validators/FormattedTest.php | Unit tests covering non-string inputs, formatting behavior, and validation pass/fail scenarios |
| tests/feature/Validators/FormattedTest.php | Feature tests demonstrating real-world usage with mask and pattern formatters |
| tests/src/Formatters/FormatterStub.php | Test stub implementing the Formatter interface for testing purposes |
| tests/src/SmokeTestProvider.php | Added smoke test entry for the Formatted validator |
| src/Mixins/*.php | Updated all mixin interfaces (Builder, Chain, AllBuilder, etc.) to include the formatted() method |
| docs/validators/Formatted.md | Comprehensive documentation with examples, behavior description, and categorization |
| docs/validators.md | Updated validator listing to include Formatted in Display and Transformations categories |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I'm going to discard this one. We can achieve the same if FormatterBuilder from string Formatter has a __invoke() |
|
Not true, |
71e21e6 to
536f975
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3b0402a to
ff1f5c7
Compare
alganet
left a comment
There was a problem hiding this comment.
Just general questions for now, trying to understand some decisions behind the change.
ff1f5c7 to
b0fbc08
Compare
The Formatted validator decorates another validator to transform how input values appear in error messages, while still validating the original unmodified input. This is useful for improving the readability of error messages by displaying values in a user-friendly formatd. The validator accepts any Respect\StringFormatter\Formatter implementation, allowing direct use of StringFormatter's fluent builder. As StringFormatter expands with more formatters in future releases, users will automatically benefit from the full range of formatting options. Assisted-by: Claude Code (Opus 4.5)
The Masked validator was a proxy for what the new Formatted validator already does, so it is being removed to reduce redundancy. All tests and documentation have been updated accordingly. Assisted-by: OpenCode (ollama-cloud/glm-4.7)
ed0211f to
6abf3a5
Compare
The Formatted validator decorates another validator to transform how input values appear in error messages, while still validating the original unmodified input.
This is useful for improving the readability of error messages by displaying values in a user-friendly formatd.
The validator accepts any Respect\StringFormatter\Formatter implementation, allowing direct use of StringFormatter's fluent builder. As StringFormatter expands with more formatters in future releases, users will automatically benefit from the full range of formatting options.
Assisted-by: Claude Code (Opus 4.5)